package com.wjc.config;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

@Configuration
public class AlipayConfig {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号,开发时使用沙箱提供的APPID，生产环境改成自己的APPID
    public static String APP_ID = "2021000121634718"; //测试
    // 应用私钥，您的PKCS8格式RSA2私钥
    public static String APP_PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCK0G6slX+KC/X2nzd9j2hlNME4j4SJBLnnVNJD8zI8bT0vyzyJJVREcCq4RLU4dVwMS1ojjHboZp2n3KX2pQcvG6wefzTPUFqWEHgaPEJkyQa0meCR+/93L+8f/wNQqswjCgpXq1e7Rjc21XFiM3ARA1BAbGRrqc6BWo3UpeJAvGpdTApPTCA/i+0I0qdfKJDodFXgYt2hXYAljXKItcJibtBxDqOAnBy9LErBlBap0woqESXlIoS70qqPCxjGEVYiCtrNweO6k5VWOePH/nzDzMzcxB8ajWq649dke5U+BUo97wScd9KMiLIq20MZRx9SFGMpPbxLWFHooJ2BvIOBAgMBAAECggEAYu/H0e4Dpup7djlonW824ttE1AFGXzolHgHQk2mkZnkdYREjpkQa2WRwrkEaQJE09/ZE2o1kuqNYvql/CFn60tKQTHQxuYj153r5fwlv8NFunA4Ih0PqgpKBhnaFcFsrf9XKJU4UC4AyHjzmwS0UNKv96MzYjfvLGVrnN6a7qZMO0nvfQIRYvpvfutPP0wdS3jOopZ6kdOcPApQ3caWGvvyVtfw8eN4vT/zF6VziTZn1KHkfRL8a3z7QOTbHR1RKOl7k+1v0CUXRNVPAtYgR02BK1qEl7oiHEEaxHDXlDWwRRPsAFijF6l4mOjGNbvpATWukF65RD10k6OQ6rjQ2gQKBgQDmEv9Bf6qipwNmq3iApJ1EdCdAP2MR4ckPEslyetd8G8QvMj5hfNkoV0y1KEaEusQfy/YQOfVQGGplAAEnVnuxdL6jCnl5HJuibVL8i7Ob0om90aTBAwJp88ECfbhiW92bHtNpmXTWm2IVUNoQdrxFANL21eS0x8OBPJNWYdYQuQKBgQCadNY1Aea8o8Pjnn9UCbMyuxjRDF5Y404i/5DVPYLxd04lXoC1pltst/kBCk8jrASQXMcn4EKG/80pdwRqevnECJDfJpNiPzWXoRFP6I4j85tk8RQj4OYMpP48QtTcgzPY5mouTX0Xka2QeXWNsrZDZ5sZjMhQmvi0GI0RAazVCQKBgCM1MwSl8cnUPwv+H4GoLzzjfYIycQmygJ8i49r1+3XNlfcW/D7U6TJoMZ/jWu9C2XJ4Nt6C0AyCv/1Ww9ZuQJ2GXQn8N1yWSSbRDgsBoemtjVCT/V9gA4WNPLMR5B6BKmdrjzSwvBV/T8ItTkGIugThPGdzkf0sOLnVOELW0/hZAoGAWc65hlS2rtSh38WWz2xcb5DuGw8QBKsWEa97rSF486GlJIFQYU57Njm6ZOpznZA1jyMDAaKZzBkMV6HGRYt/koZQhg/N/oA2TxXuFQJpM2o/3m92gG4SFSQSV0OctSLskJ9Y+ddAduXTf3+/5EYXSBYDztVW29df6Iel7k+FCNECgYATC2HCKy5PbRmjZi/l/cFFH9934pxgBRPla9Evu5IF0iMvS3AspuhQLfjtVnzH1TUsx3WeDeTND6AHgUfPxg6fsWCROM3TEBir9CNnxW+acTH4WYC0h4UrRQ+6ChaqICVXRlcDJjufARILppO+iGGjkON9cnjT35pfpJG97gCIOA==";
    // 支付宝公钥, 对应APPID下的支付宝公钥。
    public static String ALIPAY_PUBLIC_KEY ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAitBurJV/igv19p83fY9oZTTBOI+EiQS551TSQ/MyPG09L8s8iSVURHAquES1OHVcDEtaI4x26Gadp9yl9qUHLxusHn80z1BalhB4GjxCZMkGtJngkfv/dy/vH/8DUKrMIwoKV6tXu0Y3NtVxYjNwEQNQQGxka6nOgVqN1KXiQLxqXUwKT0wgP4vtCNKnXyiQ6HRV4GLdoV2AJY1yiLXCYm7QcQ6jgJwcvSxKwZQWqdMKKhEl5SKEu9KqjwsYxhFWIgrazcHjupOVVjnjx/58w8zM3MQfGo1quuPXZHuVPgVKPe8EnHfSjIiyKttDGUcfUhRjKT28S1hR6KCdgbyDgQIDAQAB";
// 服务器异步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，
    public static String notify_url = "http://localhost:8080/notifyUrl";
    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问(其实就是支付成功后返回的页面)
    public static String return_url = "http://localhost:8080/returnUrl";
    // 签名方式
    public static String sign_type = "RSA2";
    // 字符编码格式
    public static String CHARSET = "UTF-8";
    // 支付宝网关，这是沙箱的网关
    public static String gatewayUrl =
            "https://openapi.alipaydev.com/gateway.do"; //测试环境，每个人都是一样的
    // 日志输出路径
    public static String log_path = "D:\\";
    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" +
                    System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
